import 'package:flutter/material.dart';
import 'package:untitled10/TabBar/TabView1.dart';
import 'package:untitled10/TabBar/TabView2.dart';
import 'package:untitled10/TabBar/TabView3.dart';

class TabBarPage extends StatefulWidget {
  const TabBarPage({super.key});

  @override
  State<TabBarPage> createState() => _TabBarPageState();
}

class _TabBarPageState extends State<TabBarPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(length: 3, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('TabBar'),
        elevation: 0,
        bottom: PreferredSize(
          preferredSize: Size(MediaQuery.of(context).size.width, 44),
          child: Material(
            color: Colors.white,
            child: TabBar(
              controller: _tabController,
              labelColor: Colors.black,
              tabs: [
                Tab(
                  text: '1',
                ),
                Tab(
                  text: '2',
                ),
                Tab(
                  text: '3',
                ),
              ],
            ),
          ),
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: [
          TabView1(),
          TabView2(),
          TabView3(),
        ],
      ),
    );
  }
}
